<?php
/*
 * Created on Apr 3, 2006
 *
 */
require_once('config.php');
require_once('functions/general.php');
require_once('functions/sql.php');
require_once('sql/sql_area.php');
require_once('sql/sql_incident.php');
require_once('sql/sql_offender.php');
require_once('sql/sql_offense.php');
require_once('Smarty.class.php');

session_start();

$smarty = new Smarty(); 
$smarty->assign('CONFIG', $CONFIG);
logged_in_status($smarty);
$mysql_link = get_mysql_link();

$offender_id = $_GET['offender'];
assert(is_numeric($offender_id));

$offender = new Sql_offender($mysql_link);
$incident = new Sql_incident($mysql_link);

$smarty->assign('offender', $offender_id);
$smarty->assign('description', $offender->get_description($offender_id));
$smarty->assign('actions', $offender->get_actions($offender_id));
$smarty->assign('incidents', $incident->get_by_offender($offender_id, null));

#print_r($smarty);
die();

	/*
	if (isset($_GET['category']) && !isset($_GET[selection])) {
		
		switch($_GET[category]) {
			
			case "area":
				$area = new Sql_area($mysql_link);
				$smarty->assign('category', "område");
				$smarty->assign('selections', $area->get_areas());
			break;
			
			case "date":
				$incident = new Sql_incident($my_link);
				$smarty->assign('category', "dato");
				$smarty->assign('selections', $incident->get_dates());
			break;
			
			case "time":
				$incident = new Sql_incident($my_link);
				$smarty->assign('category', "tidspunkt");
				$smarty->assign('selections', $incident->get_times());
			break;
			
			case "user":
				$incident = new Sql_incident($my_link);
				$smarty->assign('category', "bidragsyter");
				$smarty->assign('selections', $incident->get_users());
			
			break;
			
			case "offender":
				$offender = new Sql_offender($my_link);
				$smarty->assign('category', "bilnummer");
				$smarty->assign('selections', $offender->get_offenders());
			
			break;
			
			case "offense":
				$offense = new Sql_offense($my_link);
				$smarty->assign('category', "synd");
				$smarty->assign('selections', $offense->get_offenses());
			break;
			
			case "all":
				$incident = new Sql_incident($my_link);
				$smarty->assign('data', $incident->get_all());
				$smarty->display('view_map.tpl');
				mysql_close($mysql_link);
			exit;
			
			default:
				$smarty->assign('title', 'Ugyldig kategori valgt');
				$smarty->assign('message', 'Ugyldig kategori valgt.');	
				$smarty->display('warning.tpl');
				mysql_close($mysql_link);
			exit;
				
			
			
		}
		$smarty->display('browse_wizard.tpl');
	}
	else if ($_GET[category] && $_GET[selection]){
		$incident = new Sql_incident($my_link);
		switch($_GET[category]) {
			case "area":
				$smarty->assign('category', "område");
				$smarty->assign('data', $incident->get_by_area($_GET[selection]));
			break;
			
			case "date":
				$smarty->assign('category', "dato");
				$smarty->assign('data', $incident->get_by_date($_GET[selection]));
			break;
			
			case "time":
				$smarty->assign('category', "tidspunkt");
				$smarty->assign('data', $incident->get_by_time($_GET[selection]));
			break;
			
			case "user":
				$smarty->assign('category', "bidragsyter");
				$smarty->assign('data', $incident->get_by_user($_GET[selection]));
			
			break;
			
			case "offender":
				$offender = new Sql_offender($mysql_link);
				$smarty->assign('category', "bilnummer");
				$smarty->assign('show_offender_info', true); //show description and actions
				$smarty->assign('offender', $_GET[selection]);
				$smarty->assign('data', $incident->get_by_offender($_GET[selection]));
				$smarty->assign('description', $offender->get_description($_GET[selection]));
				
				$smarty->assign('actions', $offender->get_actions($_GET[selection]));
			
			break;
			
			case "offense":
				$smarty->assign('category', "synd");
				$smarty->assign('data', $incident->get_by_offense($_GET[selection]));
			break;
			
			default:
				$smarty->assign('title', 'Ugyldig kategori valgt');
				$smarty->assign('message', 'Ugyldig kategori valgt.');	
				$smarty->display('warning.tpl');
				mysql_close($mysql_link);
			exit;
		}
			$smarty->display('view_map.tpl');
		
	}
	else {
		$smarty->assign('message', 'Ingen kategori valgt. Prøv hardere.');
		$smarty->assign('title', 'Ingen kategori valgt');
		$smarty->display('warning.tpl');		
	}*/
	
	mysql_close($mysql_link);
 
?>
